Next | Prev | Up | Top | Contents | Index

Testing the Driver Configuration

Different buses have different host adapter drivers that can have different features. The dsreq device driver supports an ioctl() call that retrieves the configuration of the driver for the bus where the device resides. This call fills in the fields of a structure of type dsconf (declared in sys/dsreq.h) listed in Table 5-6.

Fields of the dsconf Structure
Field NameContents
dsc_flags DSRQ flags honored by this driver (see Table 5-2)
dsc_preset DSRQ preset values (defaults) that are merged with the input ds_flags using logical OR in any request.
dsc_busNumber of this SCSI bus, as encoded in the device minor number.
dsc_imax Maximum target ID for this bus (7 for SCSI, 15 for wide SCSI).
dsc_lmax Maximum number LUN values per ID on this bus.
dsc_iomax Maximum length of a single I/O transfer.
dsc_biomax Maximum length of a buffered I/O transfer.

The code in Example 5-1 shows a function that tests if a particular flag is supported by a particular bus. The input arguments are a file descriptor for an open device special file, and a flag value (or values) from sys/dsreq.h.

Example 5-1 : Testing the Generic SCSI Configuration

uint
test_dsreq_flags(int dev_fd, uint flag)
{
   dsconf_t config;
   int ret;
   ret = ioctl(dev_fd, DS_CONF, &config);
   if (!ret) { /* no problem in ioctl */
      return (flag & config.dsc_flags);
   } else { /* ioctl failure */
      return 0; /* not supported, it seems */
   }
}
A program could use the function in Example 5-1 to find out if a particular feature is supported. For example, a test of support for the DSRQ_SYNXFER feature could be coded as follows:

if (test_dsreq_flags(the_dev, DSRQ_SYNXFER)) { /* synchronous negotiation is supported */...



Next | Prev | Up | Top | Contents | Index